Convert a pre-formatted string to a listΒΆ
Convert a string to a list.
import ast
color = "['Red', 'Green', 'White']"
print(ast.literal_eval(color))
Output:
['Red', 'Green', 'White']
import ast
color = "['Red', 'Green', 'White']"
print(ast.literal_eval(color))
Output:
['Red', 'Green', 'White']